package com.alibaba.otter.node.common.autoconfigure;

import org.springframework.core.env.PropertySource;
import org.springframework.core.io.support.EncodedResource;
import org.springframework.core.io.support.PropertySourceFactory;
import org.springframework.core.io.support.ResourcePropertySource;

import java.io.IOException;

public class OtterPropertySourceFactory implements PropertySourceFactory {

    @Override
    public PropertySource<?> createPropertySource(String name, EncodedResource resource) throws IOException {
        String conf = System.getProperty("otter.conf", "classpath*:otter.properties");
        return (conf != null ? new ResourcePropertySource(conf, resource) : new ResourcePropertySource(resource));
    }
}
